﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Title="Login" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="content" ContentPlaceHolderID="MainContent" runat="server">

	<h2>Login</h2>

	<div class="information">
		To log in, use the following credentials:
		<ul>
			<li><b>User Name:</b> Administrator</li>
			<li><b>Password:</b> password!1</li>
		</ul>
	</div>

	<% if( ( TempData["ErrorMessage"] ?? ViewData["ErrorMessage"] ) != null ){ %>
	<p class="MvcMembershipError"><% =(string)TempData["ErrorMessage"] ?? (string)ViewData["ErrorMessage"]%></p>
	<% } %>

	<% using(Html.Form( "FormsAuthentication", "FormsAuthenticate" )){ %>
	<fieldset class="MvcMembership">

		<legend>Login</legend>

		<div><label for="userName">User Name:</label> <% =Html.TextBox( "userName", new { size = 32, maxlength = 256 } ) %></div>
		<div><label for="password">Password:</label> <% =Html.Password( "password", new { size = 32 } ) %></div>
		<div><label for="rememberMe">Remember Me:</label>
			<input type="checkbox" id="rememberMe" name="rememberMe" checked="checked" value="checked" /></div>
		<% =Html.Hidden( "returnUrl", Request.QueryString["ReturnUrl"] ?? FormsAuthentication.DefaultUrl ) %>

		<div><% =Html.SubmitButton( "submit", "Login", new{ onclick = "return starterKit_mvc_membership_validateLogin();" } ) %></div>

		<div><% =Html.ActionLink("Forgot your password?", "PasswordRecovery", "FormsAuthentication") %></div>

	</fieldset>
	<% } %>

	<script type="text/javascript">
	/* <![CDATA[ */

		function starterKit_mvc_membership_validateLogin()
		{

			var userName = document.getElementById('userName').value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
			if( userName.length < 1 )
			{
				alert( 'Please enter your user name.' );
				document.getElementById('userName').focus();
				return false;
			}

			var password = document.getElementById('password').value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
			if( password.length < 1 )
			{
				alert( 'Please enter your password.' );
				document.getElementById('password').focus();
				return false;
			}
			//var pwd_minChars = <% =(int)ViewData["MinimumPasswordLength"] %>;
			//var pwd_minNonAlphaChars = <% =(int)ViewData["MinimumNonAlphaNumericCharacters"] %>;
			//if( password.length < pwd_minChars )
			//{
			//	alert( 'Passwords must be at least ' + pwd_minChars + ' characters long.' );
			//	document.getElementById('password').focus();
			//	return false;
			//}
			//var nonAlphaChars = password.replace( /[a-zA-Z0-9]*/, '' );
			//if( nonAlphaChars.length < pwd_minNonAlphaChars )
			//{
			//	alert( 'Passwords must contain at least ' + pwd_minNonAlphaChars + ' non alphanumeric characters.' );
			//	document.getElementById('password').focus();
			//	return false;
			//}

			return true;

		}

	/* ]]> */
	</script>

</asp:Content>
